# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-bundler
_gemname=bundler
pkgver=2.5.3
pkgrel=0
pkgdesc="Manage an application's gem dependencies"
url="https://bundler.io/"
arch="noarch"
license="MIT"
depends="ruby"
makedepends="
	ruby-rake
	ruby-rdoc
	"
subpackages="$pkgname-doc"
source="https://github.com/rubygems/rubygems/archive/bundler-v$pkgver.tar.gz
	manpages.patch
	"
builddir="$srcdir/rubygems-bundler-v$pkgver/bundler"
options="!check"  # tests require deps not available in main repo

build() {
	gem build $_gemname.gemspec
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--bindir "$pkgdir/usr/bin" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	local n; for n in 1 5; do
		mkdir -p "$pkgdir"/usr/share/man/man$n
		mv "$gemdir"/gems/$_gemname-$pkgver/lib/bundler/man/*.$n "$pkgdir"/usr/share/man/man$n/
	done

	rm -rf "$gemdir"/cache \
		"$gemdir"/build_info \
		"$gemdir"/doc \
		"$gemdir"/gems/$_gemname-$pkgver/man \
		"$gemdir"/gems/$_gemname-$pkgver/*.md
}

sha512sums="
571d080e43b7addb8c87769863af1146ab37db4f1adfdc1ee25119172f2db238fc1f78dc2632d0f2da3e5a1b67d63a150af3bfbf496fd9314a0f17b57ac7489e  bundler-v2.5.3.tar.gz
76c008a71af25db5dda7055c98330fcb864fe7ffb4a5de34a0ad2bea403b28e0d945faf05685abf525b98c67c305068808fc596882676bbb1eb418d83377db41  manpages.patch
"
